# 定义一个新的异常类别 MyCustomError, 继承自 Exception 或者更具体的异常如 ValueError等.
class MyCustomError(Exception):
    """My custom exception class for specific error scenarios."""
    
    def __init__(self, message="An unexpected situation occurred"):
        self.message = message
        super().__init__(self.message)


def main():
    # 模拟触发异常的情况
    user_input = "invalid data"

    if not validate_data(user_input): 
        raise MyCustomError(f"Invalid input received: {user_input}")


def validate_data(data):
    return False  # Assume validation fails


if __name__ == "__main__":
    try:
        main()
    except MyCustomError as e:
        print(f"MyCustomError caught: {e}")